import 'dart:mirrors';
typedef F<T> = int Function(T a);

class A<T>{
  late List<int> a;
  late F<int> a2;
}

main(List<String> args) {
  getAnnotation();
}

void getAnnotation() {

  ClassMirror classMirror = reflectClass(A);
  classMirror.declarations.forEach((Symbol key, DeclarationMirror value) {
    print("key:$key");
    //获取属性a和a2的反射
    if(value is VariableMirror){
      //获取属性的类型
      var type = value.type;
      print(type.reflectedType);
      //函数类型反射
      if(type is FunctionTypeMirror){
        print(type.returnType);
        type.parameters.forEach((value)=>print(value));
        return;
      }
      type.typeVariables.forEach((value)=>print(value));
      type.typeArguments.forEach((value)=>print(value));
    }
  });
}
